package com.exam.service.impl;

import com.exam.mapper.AnnouncementMapper;
import com.exam.po.Announcement;
import com.exam.po.AnnouncementExample;
import com.exam.service.AnnounceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author zhanggaoxiang
 * @ClassName AnnounceServiceImpl  通告
 * @Description TODO
 * @Date 2021/1/11 19:02
 * @Version 1.0
 **/
@Service
public class AnnounceServiceImpl implements AnnounceService {
    @Autowired
    private AnnouncementMapper announcementMapper;

    /**
     * @return java.util.List<com.exam.po.Announcement>
     * @Author zhanggaoxiang
     * @Description 分页查询所有通知
     * @Date 2021/1/11 19:56
     * @Param [page, size]
     **/
    @Override
    public List<Announcement> findAnnounceByPage(Integer page, Integer size) {
        return announcementMapper.findAnnounceByPage((page - 1) * size, size);
    }

    /**
     * @return int
     * @Author zhanggaoxiang
     * @Description 添加
     * @Date 2021/1/12 10:11
     * @Param [announcement]
     **/
    @Override
    public int addAnnounce(Announcement announcement) {
        return announcementMapper.insert(announcement);
    }

    /**
     * @return int
     * @Author zhanggaoxiang
     * @Description 删除
     * @Date 2021/1/12 10:11
     * @Param [announcementid]
     **/
    @Override
    public int deleteAnnounceById(Integer announcementid) {
        return announcementMapper.deleteByPrimaryKey(announcementid);
    }

    @Override
    public int findAnnounceCount() {
        return announcementMapper.countByExample(new AnnouncementExample());
    }
}
